CC=g++
CFLAGS=-c -Wall -I/class/ece428/libs/include/thrift -I/class/ece428/libs/include -I/usr/local/include
LDFLAGS= -pthread -lthrift -lm -pthread
SOURCES=main.cpp node.cpp NodeService.cpp mp2_types.cpp mp2_constants.cpp NodeService_client.cpp sha1.c functions.cpp
LSOURCES=listener.cpp node.cpp NodeService.cpp mp2_types.cpp mp2_constants.cpp NodeService_client.cpp sha1.c functions.cpp
OBJECTS=$(SOURCES:.cpp=.o)
LOBJECTS=$(LSOURCES:.cpp=.o)
EXECUTABLE=node
LEXECUTABLE=listener
LINK += -L/class/ece428/libs/lib -Wl,-rpath,/class/ece428/libs/lib

all: node listener

node: $(SOURCES) $(EXECUTABLE)

listener: $(LSOURCES) $(LEXECUTABLE)

$(LEXECUTABLE): $(LOBJECTS)
	$(CC) $(LINK) $(LDFLAGS) $(LOBJECTS) -o $@

$(EXECUTABLE): $(OBJECTS)
	$(CC) $(LINK) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@

clean:
	$(RM) *.o node listener
